﻿
@{
    ViewData["Title"] = "BackstageList";
}

@section Scripts
    {
    <link href="~/css/page.css" rel="stylesheet" />
    <script type="text/html" id="barAction">
        @*<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>*@
    </script>
    <script type="text/javascript">
        var selfLayer = null, page = 1, active = null;
        layui.use(['layer', 'table', 'laydate'], function () {
            var layer = layui.layer //弹层
                ,
                table = layui.table, form = layui.form; //表格
            layui.laydate.render({
                elem: '#RecordTime',
                type: 'month',
                range: true
            })

            //执行一个 table 实例
            table.render({
                id: 'dataList',
                elem: '#dataview',
                height: 'full-80',
                url: "/User/GetUserBackstageAll",
                where: { areCode: localStorage.getItem("X-AreCode") },
                request: {
                    pageName: 'index' //页码的参数名称，默认：page
                    , limitName: 'size' //每页数据量的参数名，默认：limit
                }
                , parseData: function (res) { //res 即为原始返回的数据
                    console.log(res);
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.total, //解析数据长度
                        "data": res.result.data //解析数据列表
                    };
                },
                response: {
                    statusCode: 200 //规定成功的状态码，默认：0
                },
                done: function (res, curr, count) {
                    page = curr;
                },
                page: true,
                cols: [
                    [
                        { field: 'userName', title: '用户名(昵称)' },
                        { field: 'phone', title: '手机号' },
                        {
                            field: 'sex', title: '性别', templet: function (d) {
                                if (d.sex == 0) {
                                    return '男'
                                } else { return '女' }
                            }
                        },
                        { field: 'age', title: '生日' },
                        { field: 'areaName', title: '地区' },
                        {
                            field: 'isAttest', title: '是否认证', templet: function (d) {
                                if (d.isAttest == true) {
                                    return '是'
                                } else { return '否' }
                            }
                        },
                        { field: 'attestName', title: '认证类型' },
                        { field: 'remarks', title: '备注' },
                        //  { fixed: 'right', width: '10%', title: '操作', align: 'center', toolbar: '#barAction' }
                    ]
                ]
            });

            var $b = layui.$;
            active = {
                reload: function (page) {
                    //执行重载
                    table.reload('dataList', {
                        page: {
                            curr: page || 1 //重新从第 1 页开始
                        },
                        where: {
                            sasearch: $("#keyword").val(),
                            status: $("#varTime").val(),
                            isAttest: $("#isAttest").val()
                        }

                    });
                }
            };
            $b('#search').on('click', function () {
                var type = $b(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
        });
    </script>
}

<blockquote class="layui-elem-quote layui-text layui-form">
    <div class="layui-inline">
        <label class="layui-form-label">关键字：</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="keyword" name="keyword" style="width:240px" placeholder="">
        </div>
    </div>

    <div class="layui-inline">
        <label class="layui-form-label">状态：</label>
        <div class="layui-input-inline">
            <select id="varTime" name="varTime" lay-filter="Time" autocomplete="off">
                <option value="">请选择状态</option>
                <option value="0">正常</option>
                <option value="-1">停用</option>
                <option value="1">已认证</option>
                <option value="2">未认证</option>
            </select>
        </div>
    </div>

    <div class="layui-inline">
        <label class="layui-form-label">状态：</label>
        <div class="layui-input-inline">
            <select id="isAttest" name="isAttest" lay-filter="Time" autocomplete="off">
                <option value="">认证类型</option>
                <option value="0">市场</option>
                <option value="1">产地</option>
            </select>
        </div>
    </div>

    <div class="layui-inline">
        <div class="layui-form-label">
            <button class="layui-btn" id="search" style="width: 60px; height: 28px; line-height: 28px; display: inline" data-type="reload">搜索</button>
        </div>
    </div>
</blockquote>
<table class="layui-hide" id="dataview" lay-filter="datalist"></table>

